﻿app.controller('ReportManageController', function ($scope, $http, $window, $compile, $filter, ipCookie, common, option, Upload) {
    $scope.result = {};
    $scope.dateOption = option.date;
    $scope.datetimeOption = option.datetime;


    $scope.AddReportForm = function (model) {
        var files = document.getElementById("taskfile").files;
        $scope.Submiting = true;
        $scope.LoadingMsg = "正在提交,请稍后...";
        Upload.upload({
            method: 'POST',
            url: '../ReportManage/AddReportForm',
            data: { 'model': model},
            file: files
        })
            .success(function (ret) {
                $scope.Submiting = false;
                if (ret.Code == 100) {
                    alertify.alert(ret.Msg);
                    setTimeout(function () {
                        window.location.href = "ReportFormPageList?page=1";
                    }, 2000);
                } else
                    alertify.alert(ret.Msg);
            })
            .error(function (data, status, headers, config) {
                common.error($scope);
                $scope.PageLoading = false;
                alertify.alert("请检查网络");
            })
    }

    $scope.GetReportPageList = function (model, page) {
        $scope.DataLoading = true;
        $scope.DataList = [];
        $http({
            method: 'POST',
            url: '../ReportManage/GetReportPageList',
            data: { "Name": model.Name },
            params: { 'page': page }
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                $scope.DataLoading = false;
                if (ret.Code == 100) {
                    $scope.TotalCount = ret.Data.TotalItemCount;
                    $scope.DataList = ret.Data.Data;
                }
                else {
                    alertify.alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                alertify.alert("请检查网络");
            });
    }
})